package com.sbtr.common.enums;

public enum DataTypeEnum {

    STRING("STRING", "字符型"),
    INTEGER("INTEGER", "整数型"),
    DATE("DATE", "日期型"),
    DATETIME("DATETIME", "日期时间型"),
    FLOAT("FLOAT", "浮点型类"),
    FLOAT2("FLOAT2", "浮点型"),
    JSON("JSON", "JSON"),
    ;


    String code;
    String title;

    DataTypeEnum(String code, String title) {
        this.code = code;
        this.title = title;
    }

    public String getCodeByTitle(String title) {
        DataTypeEnum[] TypeEnum = values();
        for (DataTypeEnum Enum : TypeEnum) {
            if (Enum.getTitle().equals(title)) {
                return Enum.getCode();
            }
        }
        return null;
    }

    public String getTitleByCode(String code) {
        DataTypeEnum[] TypeEnum = values();
        for (DataTypeEnum Enum : TypeEnum) {
            if (Enum.getCode().equals(code)) {
                return Enum.getTitle();
            }
        }
        return null;
    }

    public String getCode() {
        return code;
    }

    public String getTitle() {
        return title;
    }

}
